Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • stset with condition | Issue with code

    What is wrong with my stset? I am excluding duplicates with the dupdrops variable for outcome analysis where 1 are duplicates.

    stset tos, failure(vital==0) if dupdrops == 0

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(dupdrops vital) float tos
    0 1  518
    0 1 2158
    0 1 1966
    0 0  482
    0 0   24
    0 0  304
    0 1 1534
    0 0  329
    0 0  186
    1 1 2045
    0 0  215
    0 0  815
    0 0  203
    0 0  763
    0 0  431
    0 0   21
    0 1   75
    0 0  765
    0 1 2645
    0 0  262
    0 0  327
    0 1  182
    0 0  162
    0 0  138
    0 1 1468
    0 0 1296
    0 0  581
    0 1 2726
    0 1 2499
    0 1   39
    0 1  327
    1 1    0
    0 0   65
    0 1    0
    0 0  158
    0 0   58
    0 1   45
    0 1 3279
    0 1    3
    0 0   12
    0 0  313
    0 0  354
    0 0   15
    0 1  105
    0 0  245
    0 1  226
    0 0   59
    0 1  117
    0 1    0
    0 1   21
    0 0   50
    0 0  535
    0 0  142
    0 1 1784
    0 0    6
    0 0  461
    0 0  360
    0 1    0
    0 1  919
    0 0   15
    0 1  741
    0 0  138
    0 0   91
    0 1  182
    0 0    8
    0 1  366
    0 1 1107
    0 1    0
    0 0  590
    0 1  356
    0 0   12
    0 0  140
    0 0  739
    0 1   32
    0 0  205
    0 0  116
    0 0  178
    0 1    9
    0 0  792
    0 0  666
    0 0  278
    0 1   36
    0 1 1064
    0 1  808
    0 0  142
    0 0   14
    1 1 1123
    0 1   50
    1 1  433
    1 1  456
    0 0   42
    0 1  370
    0 1   21
    0 0  141
    0 1 1653
    0 0  965
    0 1 1575
    0 1 1315
    0 1    0
    0 1   70
    end
    label values vital vitallab
    label def vitallab 0 "Dead", modify
    label def vitallab 1 "Alive", modify

  • #2
    -if- is a qualifier, not an option, so is placed before the comma. That is,

    Code:
    stset tos if dupdrops == 0, failure(vital==0)

    Comment


    • #3
      Love it...Thanks Paul. By the way, I love your tutorial using rcs in survival. Hopefully, I can use it to look at pre-2010 vs post 2010 outcome in this data across multiple countries and time points although I fear I will never know if I am doing things the wrong way.

      Comment


      • #4
        Though it may not have any impact with the data shown in #1, the -stset- manually strongly recommends the use of the -if()- option to restrict records rather than the if qualifier, to remove records in a more safe way.

        Comment


        • #5
          Originally posted by Leonardo Guizzetti View Post
          Though it may not have any impact with the data shown in #1, the -stset- manually strongly recommends the use of the -if()- option to restrict records rather than the if qualifier, to remove records in a more safe way.
          How would I use the If() as an option in my situation? that is what I tried first but it kept throwing an error in the code. I was going preserve/restore to exclude certain observations, but that does not seem viable.

          Comment


          • #6
            You were almost correct in your first attempt but if option needs brackets, as indicated in the syntax.

            Code:
            stset tos, failure(vital==0) if(dupdrops == 0)

            Comment

            Working...
            X